www.gusucode.com > VC 编写的VC++工程清理工具-源码程序 > VC 编写的VC++工程清理工具-源码程序/code/VCProjectCleaner.cpp
// VCProjectCleaner.cpp : Defines the class behaviors for the application. // Download by http://www.NewXing.com #include "stdafx.h" #include "VCProjectCleaner.h" #include "CleanerDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyApp BEGIN_MESSAGE_MAP(CMyApp, CWinApp) //{{AFX_MSG_MAP(CMyApp) //}}AFX_MSG ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMyApp construction CMyApp::CMyApp() { } ///////////////////////////////////////////////////////////////////////////// // The one and only CMyApp object CMyApp theApp; ///////////////////////////////////////////////////////////////////////////// // CMyApp initialization BOOL CMyApp::InitInstance() { HANDLE hMutex; hMutex = CreateMutex(NULL,TRUE,"VCPC"); if(hMutex) { if (GetLastError() == ERROR_ALREADY_EXISTS) { CString strPrompt = "One instance of this program has existed \r\r\tJust go to find it!"; MessageBox(NULL,strPrompt,"Prompt",MB_OK |MB_ICONEXCLAMATION); return FALSE; } } // CloseHandle(hMutex); // When I added the statement above, the limit of only one instance disappeared. // That's because we can't let this handle go. AfxEnableControlContainer(); // Standard initialization #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CMyDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }